# import time
#
# def get_page(str):
#     print('正在',str)
#     time.sleep(2)#模拟延迟
#     print('完成',str)
#
# name_list = ['qq','ss','aa','ss']
#
# start_time = time.time()#计数器,开始时间
#
# for i in range(len(name_list)):
#     get_page(name_list[i])
#
# end_time = time.time()
# print('%d second'% (end_time-start_time))


import time
from multiprocessing.dummy import Pool

def get_page(str):
    print('正在',str)
    time.sleep(2)#模拟延迟
    print('完成',str)

name_list = ['qq','ss','aa','ss']

start_time = time.time()#计数器,开始时间
#实例化一个线程池
pool = Pool(4)
#将列表中每个元素传递给get_page进行
pool.map(get_page,name_list)



for i in range(len(name_list)):
    get_page(name_list[i])

end_time = time.time()
print('%d second'% (end_time-start_time))
